<html><head>
<script type="text/javascript" src="../../../../public/all/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="../../../../public/all/js/superClipBoard.min.js"></script>
<script type="text/javascript" src="../../../../public/all/js/context.js"></script>
<script src="../../../../public/all/js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../../../public/all/js/util.js"></script>

<link href="../../../css/popup.css" rel="stylesheet" type="text/css">
<style type="css/text">
.hide { display: none; }
</style>
</head>
<body
	<div class="popup">
		<div class="popupinternal order-submit2">
			<div class="col-left">
				<p>请转账至下列银行账户中：</p>
				<table class="table" style="height: 150px">
					<tbody>
						<tr>
							<td colspan="3"><img id="rechImg" src="../../../images/bank/ICBC_s.jpg"></td>
						</tr>
						<tr>
							<td style="width: 60px;">姓名：</td>
							<td><input type="text" id="copy_username" readonly="readonly" style="width: 200px"></td>
							<td><span class="copy" target="copy_username">复制</span></td>
						</tr>
						<tr>
							<td>帐号：</td>
							<td><input type="text" id="copy_cardid" readonly="readonly" style="width: 200px"></td>
							<td><span class="copy" target="copy_cardid">复制</span></td>
						</tr>
						<tr id="copy_address_tr" class="hide" style="display: table-row;">
							<td>地址：</td>
							<td><input type="text" id="copy_address" readonly="readonly" style="width: 200px"></td>
							<td><span class="copy" target="copy_address">复制</span></td>
						</tr>
						<tr class="auth_code_desc">
							<td style="font-weight: bold;">备注码：</td>
							<td><input type="text" id="auth_code" readonly="readonly" style="color: red; font-weight: bold;" value="加载中"></td>
							<td><span class="copy" target="auth_code">复制</span></td>
						</tr>
						<tr class="auth_code_desc">
							<td></td>
							<td colspan="2" id="bzm-clue"></td>
						</tr>
					</tbody>
				</table>

				<div class="three-second">
					<h4>存款信息</h4>
					<div class="post-info">
						<p>
							存款金额：<input type="text" id="amount">
							<div style="padding-left: 80px;">单笔下限：<span class="min" style="color:red">0</span> 
								&nbsp;&nbsp;&nbsp;上限：<span class="max" style="color:red">0</span></div>
						</p>
						<p>
							<span id="nickname_desc">账号信息</span>：<input type="text" id="userName" placeholder="请填写账户姓名">
						</p>
						<p id="payeeInfo_desc" class="hide">
							认证姓名：<input type="text" id="payeeInfo" placeholder="请填写支付宝实名认证姓名">
						</p>
						<p>
							存款时间：<input style="width: 70px;" name="cn_date" type="text" id="cn_date" value="" size="10" maxlength="10">
							<input style="width: 20px;" name="s_h" id="s_h" type="text" size="2" maxlength="2" value="00">
							  时
							<input style="width: 20px;" name="s_i" id="s_i" type="text" size="2" maxlength="2" value="00">
							分
						</p>
						<p id="rebate_html" class="hide" style="display: none;">
							赠送金额：<span id="rebate_money">0</span>
						</p>
						<p id="fee_html" class="hide" style="display: none;">
							手续费：<span id="fee_money">0</span>
						</p>
					</div>
				</div>
				
				<div class="fullwidth">
					<div class="container">
						<input type="submit" class="button" onclick="unPay();" value="取消订单" style="margin-right: 50px;">
						<input type="submit" class="button" id="btnSubmit1" onclick="doPay();" value="提交充值">
					</div>
				</div>
			</div>
			<div class="col-right">
				<div class="jc-info auth_code_desc_hide">
					<h4>复制提示</h4>
					<p>浏览器不支持复制,点击“复制”后请使用Ctrl+C或者鼠标右键菜单</p>
				</div>
				<div id="bank-info1" class="bank-info hide" style="height: 180px;width: 100%">
					<h4>扫一扫支付</h4>
					<img id="payImg" width="140" height="140" style="margin-top: 0px;">
				</div>
				
				<div id="bank-info2" class="bank-info hide" style="display: block;">
					<h4>常用网银网址</h4>
					<div class="bank-info-left">
						<p><a target="_blank" href="http://www.icbc.com.cn/">工商银行</a></p>
						<p><a target="_blank" href="http://www.ccb.com/">建设银行</a></p>
						<p><a target="_blank" href="http://www.abchina.com/cn/">农业银行</a></p>
						<p><a target="_blank" href="http://www.bankcomm.com">交通银行</a></p>
						<p><a target="_blank" href="http://www.boc.cn/">中国银行</a></p>
						<p><a target="_blank" href="http://www.cebbank.com/">光大银行</a></p>
						<p><a target="_blank" href="http://www.cmbc.com.cn/">民生银行</a></p>
						<p><a target="_blank" href="http://www.psbc.com/">邮政银行</a></p>
					</div>
					<div class="bank-info-right">
						<p><a target="_blank" href="http://www.cmbchina.com/">招商银行</a></p>
						<p><a target="_blank" href="http://www.cib.com.cn/">兴业银行</a></p>
						<p><a target="_blank" href="http://bank.ecitic.com/">中信银行</a></p>
						<p><a target="_blank" href="http://www.cgbchina.com.cn/">广发银行</a></p>
						<p><a target="_blank" href="http://www.spdb.com.cn/">浦发银行</a></p>
						<p><a target="_blank" href="http://www.hxb.com.cn/">华夏银行</a></p>
						<p><a target="_blank" href="http://www.baidu.com/">其他银行</a></p>
					</div>
				</div>
				
				<div style="padding-top: 10px;" class="auth_code_desc hide">
					<img src="../../../images/rech_course_web.jpg" width="182px;">
				</div>

			</div>

		</div>
	</div>
	

	
<script type="text/javascript">
	var layer = parent.layer;
	var type = parent.context.center.chargeType;

	// 生成付款码
    var code = '';
    for (var i = 0; i < 4; i++)
        code += '' + parseInt(Math.random() * 10);
	layer.alert("在 “付款说明” 或 “备注” 处填写备注码，提交订单后才能秒到！备注码是4位数，不要填写中文。", {icon : 0});

	$(function() {
		$(".copy").click(function(e) {
			var id = $(e.currentTarget).attr("target");
			if (!id) return;
			console.log(id, $("#" + id).val());
			superClipBoard.copy($("#" + id).val());
			alert("复制成功");
		});
		
		var dateStr = new Date().Format('yyyy-MM-dd HH:mm:ss');
		$('#cn_date').val(dateStr.substr(0, 10));
		$('#s_h').val(dateStr.substr(11, 2));
		$('#s_i').val(dateStr.substr(14, 2));

		$("#auth_code").val(code);
		switch (type) {
			case "bank": {
				// 银行转账
				var bank = parent.getSelectBankInfo();
				$('#copy_username').val(bank.name);
				$('#copy_cardid').val(bank.account);
				$('#copy_address_tr').show();
				$('#copy_address').val(bank.addr);
				$("#bzm-clue").html('请在转账 <span style="color: red;">备注</span> 中填写备注码');
				$('#rechImg').attr('src', '../../../images/bank/' + Util.getBankIcon(bank.bank) + '_s.jpg');
				$(".min").html(bank.min || 0);
				$(".max").html(bank.max || 0);
				break;
			}
			case "alipay": {
				// 支付宝支付
				var bank = parent.getSelectBankInfo();
				$('#copy_username').val(bank.name);
				$('#copy_cardid').val(bank.account);
				$('#copy_address_tr').hide();
				$("#bzm-clue").html('请在支付宝 <span style="color: red;">添加备注</span> 中填写备注码');
				$('#rechImg').attr('src', '../../../images/bank/ZFB_s.jpg');
				$(".min").html(bank.min || 0);
				$(".max").html(bank.max || 0);
				$("#bank-info2").hide();
				$("#bank-info1").show();

				var url = parent.context.config.url.replace(":9090", "");
				$("#payImg").attr("src", url + bank.qrcode);
				$(".auth_code_desc").show();
				$(".auth_code_desc_hide").hide();
				$("#payeeInfo_desc").show();
				break;
			}
			case "wechat": {
				// 微信支付
				var bank = parent.getSelectBankInfo();
				$('#copy_username').val(bank.name);
				$('#copy_cardid').val(bank.account);
				$('#copy_address_tr').hide();
				$("#bzm-clue").html('请在微信支付 <span style="color: red;">备注</span> 中填写备注码');
				$('#rechImg').attr('src', '../../../images/bank/WEIXIN_s.jpg');
				$(".min").html(bank.min || 0);
				$(".max").html(bank.max || 0);
				$("#bank-info2").hide();
				$("#bank-info1").show();

				var url = parent.context.config.url.replace(":9090", "");
				$("#payImg").attr("src", url + bank.qrcode);
				break;
			}
			case "cft": {
				// qq钱包
				var bank = parent.getSelectBankInfo();
				$('#copy_username').val(bank.name);
				$('#copy_cardid').val(bank.account);
				$('#copy_address_tr').hide();
				$("#bzm-clue").html('请在QQ支付 <span style="color: red;">备注</span> 中填写备注码');
				$('#rechImg').attr('src', '../../../images/bank/CFT_s.jpg');
				$(".min").html(bank.min || 0);
				$(".max").html(bank.max || 0);
				$("#bank-info2").hide();
				$("#bank-info1").show();

				var url = parent.context.config.url.replace(":9090", "");
				$("#payImg").attr("src", url + bank.qrcode);
				break;
			}
		}
	});
	
	var submitFlag = false;
	function doPay() {
		// 防止重复提交
		if(submitFlag) {
			return;
		}
		
		var amount = $('#amount').val();
		var re=/^[0-9]+.?[0-9]*$/;
		if (!re.test(amount)) {
			layer.alert('请输入正确的金额', {icon : 2});
			return false;
		}
		if (!amount) {
			layer.alert('请输入存款金额', {icon : 2});
			return false;
		}

		var minMoneu = parseInt($(".min").html());
		if(parseInt(amount) < minMoneu) {
			layer.alert('存款金额至少'+minMoneu+'元', {icon : 2});
			return false;
		}
		var max = parseInt($(".max").html());
		if(amount > max){
			layer.alert('存款金额超过' + max + '元', {icon : 2});
			return false;
		}
		var userName = $('#userName').val();
		if (!userName) {
			layer.alert('请输入用户姓名', {icon : 2});
			return false;
		}
		
		var payeeInfo=$("#payeeInfo").val();
		var cn_date = $('#cn_date').val();
		var s_h = $('#s_h').val();
		var s_i = $('#s_i').val();
		var depostitTime = cn_date + " " + s_h + ":" + s_i + ":00";
		var dateRegx=/^(d{4})-(d{2})-(d{2}) (d{2}):(d{2}):(d{2})$/;

		if(dateRegx.exec(depostitTime)) {
			layer.alert('存款时间格式不正确', {icon : 2});
			return false
		}
		
		amount = parseInt(parseFloat(amount) * 100);
		submitFlag = true;

		if (type == 'bank') {
			// 银行转账
			var bank = parent.getSelectBankInfo();
			var memo = {
				time: depostitTime,
				bank: bank.bank,
				name: bank.name,
				account: bank.account,
				requestAccount: userName,
				code: code,
			};
			parent.CMD.deposit(null, "", amount, "handOper", "bank", memo, function(r) {
				submitFlag = false;
				layer.closeAll();
				if (r.code == 0 || r.code === undefined) {
					layer.alert('存款信息提交成功，请等待客服审核', {icon : 1});
				}
				else
					layer.alert(r.message, {icon: 2});
			});
		}
		else if (type == 'alipay') {
			// 支付宝转账
			var rz = $("#payeeInfo").val().trim();
			if (!rz) {
				layer.alert('请填写支付宝实名认证姓名', {icon : 2});
				return;
			}
			var bank = parent.getSelectBankInfo();
			var memo = {
				time: depostitTime,
				name: bank.name,
				account: bank.account,
				requestAccount: userName,
				code: code,
				alipay: rz,
			};
			parent.CMD.deposit(null, "", amount, "handOper", "alipay", memo, function(r) {
				submitFlag = false;
				layer.closeAll();
				if (r.code == 0 || r.code === undefined) {
					layer.alert('存款信息提交成功，请等待客服审核', {icon : 1});
				}
				else
					layer.alert(r.message, {icon: 2});
			})
		}
		else if (type == 'wechat') {
			// 微信支付
			var bank = parent.getSelectBankInfo();
			var memo = {
				time: depostitTime,
				name: bank.name,
				account: bank.account,
				requestAccount: userName,
				code: code,
			};
			parent.CMD.deposit(null, "", amount, "handOper", "wechat", memo, function(r) {
				submitFlag = false;
				layer.closeAll();
				if (r.code == 0 || r.code === undefined) {
					layer.alert('存款信息提交成功，请等待客服审核', {icon : 1});
				}
				else
					layer.alert(r.message, {icon: 2});
			})
		}
		else if (type == 'cft') {
			// qq
			var bank = parent.getSelectBankInfo();
			var memo = {
				time: depostitTime,
				name: bank.name,
				account: bank.account,
				requestAccount: userName,
				code: code,
			};
			parent.CMD.deposit(null, "", amount, "handOper", "cft", memo, function(r) {
				submitFlag = false;
				layer.closeAll();
				if (r.code == 0 || r.code === undefined) {
					layer.alert('存款信息提交成功，请等待客服审核', {icon : 1});
				}
				else
					layer.alert(r.message, {icon: 2});
			})
		}
	}
	
	function unPay() {
		layer.confirm("确定要取消此笔订单吗？", function() {
			layer.closeAll();
		});
	}

	$(function() {
		parent.$("body").resize();
		setTimeout(function() {
			parent.$("body").resize();
		}, 100);
	})
</script>
</body></html>